package cn.pzaily.orange.core.utils;

import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @PackageName: cn.pzaily.orange.core.utils
 * @Description:
 * @Author: Pang
 * @Date: 2021-05-11 22:21
 */
public class PoiUtils {

    public static File createExcelFile(Workbook workbook, String fileName) {
        File file = null;
        OutputStream stream = null;
        try {
            file = File.createTempFile(fileName, ".xlsx");
            stream = new FileOutputStream(file.getAbsoluteFile());
            workbook.write(stream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.close(workbook);
            IOUtils.close(stream);
        }
        return file;

    }
}
